package lambda;

import javafx.util.Callback;
import org.junit.Test;
import org.omg.CORBA.UserException;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.function.BiConsumer;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.stream.Collectors;

/**
 * @Author Klys
 * @Date 2023/4/24 9:43
 * @Description
 * @Version 1.0
 */
public class Dmo01 {
    /**
     * 输出list
     */
    @Test
    public void test() throws Exception {
        String[] array = {"aaaa", "bbbb", "cccc"};
        List<String> list = Arrays.asList(array);

        //Java 7
        for (String s : list) {
            System.out.println(s);
        }

        //Java 8
        list.forEach(s -> System.out.println(s));
        list.forEach(System.out::println);

        Function<String, String> function = User::eat;
        System.out.println(function.apply("西瓜"));

        Function<String, String> a = (String k) -> {
            return new User("刘豫嵩").toString();
        };
        System.out.println(a.apply(""));

        Function<String, String> function1 = User::eat;
        System.out.println(function1.apply("香蕉"));

        Function<User, String> function2 = User::play;
        System.out.println(function2.apply(new User()));

        Consumer consumer = System.out::print;
        consumer.accept("klys");

        System.out.println("----------");

        List<String> list1 = Arrays.asList("liu", "sen", "klys");
        List<String> list2 = list1.stream().filter(value -> value == "klys").map(s -> {
            return s += "+map处理返回";
        }).collect(Collectors.toList());
        System.out.println(list2);

    }

}
